<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>渠道列表</title>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css">
    <link rel="stylesheet" href="__PUBLIC__/static/css/style.css">
    <link rel="icon" href="__PUBLIC__/static/image/code.png">
</head>
<body class="body">
  <div class="tab-top">
{if ahuthbtn('add')}
<a class="layui-btn site-demo-active layui-btn-sm" href="{:url('admin/Platform/add')}"><i class="layui-icon layui-icon-add-circle"></i>添加渠道信息</a>
{/if}

<div class="search">
  <form class="layui-form" action="">
  <div class="layui-inline">
    <input class="layui-input layui-input-sm" name="search" placeholder="请输入平名称" id="search-elm" autocomplete="off" value="{$search}">
  </div>
  <button class="layui-btn site-demo-active layui-btn-sm search-btn" data-type="reload">搜索</button>
</form>
</div>
</div>
<table class="layui-table" lay-filter="parse-table-demo" id="test33" style="display:none">
    <thead>
    <tr>
      <th lay-data="{type:'checkbox'}"><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose"></th>
        <th lay-data="{field:'id', width:80, sort: true}">id</th>
        <th lay-data="{field:'name', width:200 }">名称</th>
        <th lay-data="{field:'contact', minwidth:80, sort: true}">联系人</th>
        <th lay-data="{field:'mobile', minwidth:80, sort: true}">手机</th>
        <th lay-data="{field:'remark', minwidth:80, sort: true}">备注</th>
        <th lay-data="{field:'status', width:100, templet: '#statusTpl', unresize: true}">状态</th>
        <th lay-data="{field: 'right', width:178, align:'center'}">操作</th>
    </tr>
    </thead>
    <tbody>
{foreach $list as $key=>$vo}
    <tr>
      <td><input type="checkbox" name="" lay-skin="primary" data-id="{$vo.id}"></td>
        <td>{$vo.id}</td>
        <td>{$vo.name|raw}</td>
        <td>{$vo.contact}</td>
        <td>{$vo.mobile}</td>
        <td>{$vo.remark}</td>
        <td>{$vo.status}</td>
        <td>
          <!-- <a data-href="{:url('admin/Partition/add',['id'=>$vo.id])}" class="addplatform">添加分区</a>  --> 
          {if ahuthbtn('edit')}
          <a data-href="{:url('admin/Platform/edit',['id'=>$vo.id])}" class="layui-btn layui-btn-xs editplatform"><i class="layui-icon layui-icon-edit"></i></a> 
          {/if}
          {if ahuthbtn('delete')}
          <a data-href="{:url('admin/Platform/delete',['id'=>$vo.id])}" class="layui-btn layui-btn-danger layui-btn-xs delplatform"><i class="layui-icon layui-icon-delete"></i></a>
          {/if}
        </td>
    </tr>
{/foreach}
    </tbody>
</table>
<div class="list-page">{$page|raw}</div>
<script type="text/html" id="statusTpl">
  <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="禁|否" lay-filter="lockstatus" {{ d.status == 0 ? 'checked' : '' }} >
</script>
<script type="text/javascript" src="__PUBLIC__/layui/layui.js"></script>
<script src="__ADMIN__/js/comm.js" charset="utf-8"></script>
<script type="text/javascript">
    // you code ...
    layui.use(['form','table','layer','admin'], function(){
      var $ = layui.jquery
          ,form = layui.form
          ,table = layui.table
          ,layer = layui.layer
          ,admin = layui.admin;
    
          table.init('parse-table-demo', { //转化静态表格
            //height: 'full-500'
          }); 
    
    
    $('.addplatform').click(function(event) {
          var url = $(this).attr('data-href');
          admin.actAuth(url,function(){
            window.location.href=url ;
          });
    });
    
    
    $('.delplatform').click(function(event) {
            layer.confirm('真的删除行么-1', function(index){
           var url = $(this).attr('data-href');
            //admin.actAuth(url,function(){
            $.get(url,function(data){
            if (data.code === 0) {
              layer.msg(data.msg);
            }else{
              obj.del();
              layer.msg(data.msg);
            }
            });
    
          });
    });
    
    
    $('.editplatform').click(function(event) {
        var url = $(this).attr('data-href');
        admin.actAuth(url,function(){
          window.location.href=url ;
        });
    });
    
   
      //监听锁定操作
      form.on('switch(lockstatus)', function(obj){
        if(obj.elem.checked === true){
           var isval =0;
        }else{
          var isval =1;
        }
        $.post("{:url('admin/Platform/quickedit')}",{id:this.value,status:isval},function(data,status){
            if(data){
              layer.tips(data.msg,obj.othis);
            }
        });
      });
    
    





});
</script>
</body>
</html>